cmake_minimum_required(VERSION 3.16)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 11)

project(sim C CXX ASM)

add_compile_options ( -Werror
  -Wall -Wextra -Winline -Winit-self -Wno-unused-function
  -Wuninitialized -Wno-sequence-point -Wno-inline -Wno-unknown-pragmas
  -Woverloaded-virtual -Wno-unused-parameter -Wno-missing-field-initializers -pipe)

# Use ccache if installed
find_program (CCACHE_PROGRAM ccache)
if (CCACHE_PROGRAM)
  set_property (GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
  message ("-- Using ccache")
endif ()

if (CMAKE_BUILD_TYPE MATCHES "^[Rr]elease")
    add_compile_options(-O3)
elseif (CMAKE_BUILD_TYPE MATCHES "^[Ff]ast[Dd]ebug")
    add_compile_options(-O3 -g)
elseif (CMAKE_BUILD_TYPE MATCHES "^[Dd]ebug")
    add_compile_options(-O0 -g)
elseif (CMAKE_BUILD_TYPE MATCHES "^[Pp]rofile")
    add_compile_options(-O3 -pg -g -ftime-trace)
else()
    message (FATAL_ERROR "Please provide a CMAKE_BUILD_TYPE: -DCMAKE_BUILD_TYPE=Release|FastDebug|Debug|Profile")
endif()

include_directories(inc)
file(GLOB_RECURSE SOURCES "src/*.cpp")

add_executable(${PROJECT_NAME} ${SOURCES})